package com.huawei.hwCloudJs.service.a.a;

import android.text.TextUtils;
import android.util.Log;
import com.huawei.hwCloudJs.service.http.a.d;
import com.huawei.hwid.core.constants.HwAccountConstants;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Map;
import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;

public class c extends d {
    private static final String a = "AuthResponseBean";
    private static final String b = "NSP_STATUS";
    private int c = -1;
    private List<String> d;
    private List<String> e;

    public List<String> a() {
        return this.d;
    }

    public void a(int i) {
        this.c = i;
    }

    public void a(String str, Map<String, String> map) {
        if (!TextUtils.isEmpty(str)) {
            try {
                JSONObject jSONObject = new JSONObject(str);
                String str2 = (String) map.get(b);
                if (TextUtils.isEmpty(str2) || "0".equals(str2)) {
                    JSONObject optJSONObject;
                    a(0);
                    JSONArray optJSONArray = jSONObject.optJSONArray("scopes");
                    if (optJSONArray != null) {
                        try {
                            List arrayList = new ArrayList();
                            int length = optJSONArray.length();
                            for (int i = 0; i < length; i++) {
                                optJSONObject = optJSONArray.optJSONObject(i);
                                if (optJSONObject != null) {
                                    JSONArray optJSONArray2 = optJSONObject.optJSONArray("permissions");
                                    if (optJSONArray2 != null) {
                                        int length2 = optJSONArray2.length();
                                        for (int i2 = 0; i2 < length2; i2++) {
                                            arrayList.add(optJSONArray2.getString(i2));
                                        }
                                    }
                                }
                            }
                            a(arrayList);
                        } catch (JSONException e) {
                            Log.e(a, "jsonArray JSONException");
                            return;
                        }
                    }
                    optJSONObject = jSONObject.optJSONObject("appAttr");
                    if (optJSONObject != null) {
                        Object optString = optJSONObject.optString("securityUrl");
                        if (!TextUtils.isEmpty(optString)) {
                            b(Arrays.asList(optString.split(HwAccountConstants.KEY_COMMA)));
                            return;
                        }
                        return;
                    }
                    return;
                }
                try {
                    a(Integer.parseInt(str2));
                } catch (NumberFormatException e2) {
                    a(-1);
                }
            } catch (JSONException e3) {
                Log.e(a, "resultObj JSONException");
            }
        }
    }

    public void a(List<String> list) {
        this.d = list;
    }

    public int b() {
        return this.c;
    }

    public void b(List<String> list) {
        this.e = list;
    }

    public String[] c() {
        return new String[]{b};
    }

    public List<String> d() {
        return this.e;
    }
}
